package com.coder.rental.service.impl;

import com.coder.rental.service.IMailService;
import com.coder.rental.vo.MailVo;
import jakarta.annotation.Resource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

public class IMailServiceImpl implements IMailService {
    @Resource
    private JavaMailSender javaMailSender;
    /**
     * 发送邮件功能实现
     *
     * @param mail 邮件信息对象，包含发件人、收件人、主题、内容等信息
     */
    @Override
    public void sendMail(MailVo mail) {
        // 创建简单邮件消息对象
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mail.getFrom());
        message.setTo(mail.getTo());
        message.setSubject(mail.getSubject());
        message.setText(mail.getContent());
        message.setCc(mail.getFrom());

        // 发送邮件
        javaMailSender.send(message);
    }

}
